package com.game.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.game.pojo.po.ActivationCode;
import com.game.dao.ActivationCodeDao;
import com.game.service.ActivationCodeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lvhao
 * @since 2020-07-25
 */
@Service
public class ActivationCodeServiceImpl extends ServiceImpl<ActivationCodeDao, ActivationCode> implements ActivationCodeService {
    @Autowired
    private ActivationCodeDao activationCodeDao;

    @Override
    public List<ActivationCode> getAll() {
        QueryWrapper<ActivationCode> queryWrapper = new QueryWrapper<>();
        return activationCodeDao.selectList(queryWrapper);
    }

    @Override
    public ActivationCode getByCode(String code) {
        QueryWrapper<ActivationCode> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("code",code);
        return activationCodeDao.selectOne(queryWrapper);
    }

    @Override
    public boolean deleteByCode(String code) {
       /* Map<String,Object> map = new HashMap<>();
        map.put("code",code);*/
        QueryWrapper<ActivationCode> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("code",code);
        if(activationCodeDao.delete(queryWrapper) > 0){
            return true;
        }
        return false;
    }
}
